
package blackjack;





public class Deck {
   private Card[] baraja=new Card[52];
   private int usadas;

    public Deck() {
        int contador =0;
        for(int suit=0;suit<=3;suit++){
            for(int value = 1; value<=13;value++){
                baraja[contador]= new Card(value,suit);
                contador++;
            }
        }
    }

    public Card[] getBaraja() {
        return baraja;
    }

    
    public int getUsadas() {
        return usadas;
    }

    public void setUsadas(int usadas) {
        this.usadas = usadas;
    }
    
    public void shuffle(){
        for(int i=baraja.length;i>0;i--){
            int aleatorio = (int)(Math.random()*(i+1));
            Card aux = baraja[i];
            baraja[i]=baraja[aleatorio];
            baraja[aleatorio]=aux;
        }
    }
    
   public Card dealCard(){
       Card aux=null;
       if(this.usadas < baraja.length){
            int i=this.usadas;
           aux=baraja[i];
           this.usadas++;
          
       }
       else{
           throw new java.lang.IllegalStateException("no hay cartas que servir");
       }
       return aux;
       
   }
   public boolean areCardsLeftToDeal(){
       return this.usadas <= baraja.length;
   }
   
   
   
}
